#!/bin/bash
EGO=boc-go/target/boc-go
ERS=boc-rs/target/release/boc-rs
EKT=boc-kt/boc-kt
ECJ=boc-cj/target/boc-cj

#events=10000
queue=256
etype=0
esize=256
verbose=

TIMER='/usr/bin/time'
export TIME='%e,%S,%U,%P,%M'


# setup cangjie env, increase heap size
source /opt/cangjie/envsetup.sh
export cjHeapSize=1GB


while getopts "e:q:t:s:" opt; do
  case ${opt} in
    e )
      events=$OPTARG
      ;;
    q )
      queue=$OPTARG
      ;;
    t )
      etype=$OPTARG
      ;;
    s )
      esize=$OPTARG
      ;;
  esac
done

echo "program,etype,worker,event,time,speed"
for worker in 100 1000 5000 
do
    for events in 100 1000 10000
    do
      for etype in 0 1 3
      do
          ${TIMER} ${EGO} -c -w ${worker} -e ${events} -q ${queue} -t ${etype} -s ${esize}
          ${TIMER} ${ERS} -c -w ${worker} -e ${events} -q ${queue} -t ${etype} -s ${esize}
          ${TIMER} ${EKT} -c -w ${worker} -e ${events} -q ${queue} -t ${etype} -s ${esize}
          ${TIMER} ${ECJ} -c -w ${worker} -e ${events} -q ${queue} -t ${etype} -s ${esize}
      done
    done
done

